const {
    parseStudentId
} = require('../../utils/helpers.js');

module.exports = async (ctx, next) => {
    // console.log(" ctx.params",  ctx.params);
    // console.log(" ctx.query",  ctx.query);
    const { model, id } = ctx.params;
    if(model==='student'){
        const student = await strapi.services.student.fetch({id});
        const data = {
            device:student.device.id,
            action:'student-del',
            data:{
                user_id:parseStudentId(id)
            }
        };
        await strapi.plugins['content-manager'].services['contentmanager'].add({ model: 'task' }, data, 'task');
    }
    await next();

};
